//
//  ButtonView.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/11/7.
//

import SwiftUI

struct ButtonView: View {
    var image: String
    var action: () -> Void
    
    var body: some View {
        Button(action: {
            action()
        }, label: {
            Circle()
            // 有模糊背景效果的材质
                .fill(.ultraThinMaterial)
                .frame(width: boundsWidth * 0.12)
                .shadow(color: .black.opacity(0.15), radius: 20, x: 0, y: 10)
                .overlay {
                    Circle()
                        .foregroundStyle(LinearGradient(gradient: Gradient(colors: [.red, .orange, .yellow]), startPoint: .top, endPoint: .bottom))
                        .rotationEffect(.degrees(135))
                }
                .overlay {
                    Image(systemName: image)
                        .foregroundStyle(.white)
                        .font(.system(size: boundsWidth * 0.06, weight: .bold))
                }
        })
        .padding(.horizontal)
    }
}

struct BackButtonView: View {
    var image: String
    var action: () -> Void
    
    var body: some View {
        Button(action: {
            action()
        }, label: {
            Image(systemName: image)
                .frame(width: 30, height: 30)
                .overlay {
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(lineWidth: 2)
                }
                .bold()
                .foregroundStyle(.red)
        })
        .padding()
    }
}

#Preview {
    ButtonView(image: "arrow.left") {}
}

#Preview {
    BackButtonView(image: "arrow.left") {}
}
